function [vv,flag] = Steady_set_iter(vv_guess,varargin)  

% ===== Initial Variable Construction =====

Par = varargin{1};
Step = varargin{2};
rr_A = varargin{3}(1);
rr_B = varargin{3}(2);

Trans_innov = Step{2};
Trans_fail = Step{3};
Trans_exo  = Step{4};
prft_fnc_A = Step{5}(:,1);
prft_fnc_B = Step{5}(:,2);
          
Param = structvars(Par);
for ctr0 = 1:size(Param,1); eval(Param(ctr0,:)); end

vv = exp(vv_guess);
iter_ss = 0;
diff = 1;


while iter_ss<10*time_ss && diff>10^-10
    
    % ===== R&D Decisions using Vt+dt =====
    
    vv_iA_next = vv(1:length(vv)/2);
    vv_iB_next = vv(1*length(vv)/2+1:2*length(vv)/2);

    x_iA = ((Trans_innov'*vv_iA_next-...
            vv_iA_next)/(alfa_A*(1-tau_A))).^(1/(gama_A-1));
    x_iB = ((Trans_innov'*vv_iB_next-...
            vv_iB_next)/(alfa_B*(1-tau_B))).^(1/(gama_B-1));

    x_eA = ((Trans_innov'*vv_iA_next-0)/...
                    alfa_eA).^(1/(gama_eA-1));
    x_eB = ((Trans_innov'*vv_iB_next-0)/...
                    alfa_eB).^(1/(gama_eB-1));
                
    x_iA = max(x_iA,0); x_iB = max(x_iB,0);
    x_eA = max(x_eA,0); x_eB = max(x_eB,0);

    % ===== Value Functions at t =====
    
    v_iA = (prft_fnc_A-(1-tau_A)*alfa_A.*x_iA.^gama_A/gama_A+...
           x_iA.*(Trans_innov'*vv_iA_next-...
           vv_iA_next)-x_eA.*vv_iA_next+...
           flip(x_eB+x_iB).*(Trans_fail*vv_iA_next-vv_iA_next)+...
           dlt*Trans_exo*vv_iA_next-(rr_A-1/dt)*vv_iA_next)*dt;

    v_iB = (prft_fnc_B-(1-tau_B)*alfa_B.*x_iB.^gama_B/gama_B+...
           x_iB.*(Trans_innov'*vv_iB_next-...
           vv_iB_next)-x_eB.*vv_iB_next+...
           flip(x_eA+x_iA).*(Trans_fail*vv_iB_next-vv_iB_next)+...
           dlt*Trans_exo*vv_iB_next-(rr_B-1/dt)*vv_iB_next)*dt;
        
    vv_prev = [v_iA; v_iB];
    
    F_diff = vv_prev-vv;
    
    diff = max(abs(F_diff)/dt);
    
    vv = max(vv_prev,10^-4);
    
    iter_ss = iter_ss+1;
    
    Prev(:,iter_ss) = vv_prev;
     
end


if diff<10^-8
    
    flag = 1; 

else
    
    flag = 0;
    
end

